<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <link rel="stylesheet" th:href="@{/static/element/index.css}"/>
</head>
<body>
<style>
    .el-input-item {
        width: 260px;
    }

</style>
<div id="app">
    <template>
        <el-form :model="formData" ref="formData" :rules="rules" label-width="100px"
                 style="margin-top: 5%;display: flex;flex-direction: row;align-items: center;flex-wrap: wrap;justify-content: space-between;margin-right: 5%">
            <el-form-item label="医生">
                <el-select v-model="formData.doctor" placeholder="请选择医生" class="el-input-item"
                           size="small">
                    <el-option
                            v-for="item in doctorOptions"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="预约时间" prop="time">
                <el-date-picker clearable size="small" style="width: 260px"
                                v-model="formData.time"
                                type="date"
                                value-format="yyyy-MM-dd"
                                placeholder="选择预约时间">
                </el-date-picker>
            </el-form-item>
            <el-form-item label="患者" prop="userName">
                <el-input readonly="true" class="el-input-item" size="small" v-model="formData.userName"
                          placeholder="请输入患者"/>
            </el-form-item>
        </el-form>
        <div style="text-align: center;margin-top: 5%">
            <el-button size="small" @click="closePage">取 消</el-button>
            <el-button size="small" type="success" @click="handleSubmit2(1)" v-show="status == 3">通过</el-button>
            <el-button size="small" type="danger" @click="handleSubmit2(2)"  v-show="status == 3">不通过</el-button>
        </div>
    </template>
</div>
</body>
<script th:src="@{/static/js/axios.min.js}"></script>
<script th:src="@{/static/js/request.js}"></script>
<script th:src="@{/static/js/common.js}"></script>
<script th:src="@{/static/api/admin/sysReservation.js}"></script>
<script th:src="@{/static/js/vue.min.js}"></script>
<script th:src="@{/static/element/index.js}"></script>
<script th:src="@{/static/js/jquery.min.js}"></script>
<script th:src="@{/static/layer/layer.js}"></script>
<script>
    let id = getQueryString("id");
    let status = getQueryString("status");
    new Vue({
        el: '#app',
        data() {
            return {
                dialogVisible: false,
                formData: {},
                doctorOptions: [],
                rules: {
                    createTime: [
                        {required: true, message: "创建时间不能为空", trigger: "blur"}
                    ],
                }
            }
        },
        created() {
            if (id) {
                detail(id).then((res) => {
                    if (res.code === '200') {
                        this.formData = res.data
                    }
                });
            } else {
                this.formData = {}
            }
            // 在这里调用查询患者列表
            let queryParam = {};
            getDoctorList(queryParam).then(res => {
                this.doctorOptions = res.data.list;
            })
        },
        methods: {
            handleSubmit2(index){
                let params = {
                    id:this.formData.id,
                    status:index,
                };
                let text = index == 1 ? '通过':'不通过';
                update(params).then(res=>{
                    if(res.code == 200){
                        this.$notify({
                            title:'审核'+text+ '成功',
                            message: '成功',
                            type: 'success'
                        });
                        closePage()
                    }
                })
            },
            handleSubmit() {
                if (id) {
                    addOrUpdate('/admin/sysReservation/update', this);
                } else {
                    addOrUpdate('/admin/sysReservation/add', this);
                }
            },

        }
    });
</script>
</html>
